package com.cn.system.common.filter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.HandlerInterceptor;

/**
 * 拦截器
 * @author Administrator
 *
 */
public class LogCostInterceptor implements HandlerInterceptor{
	long start = System.currentTimeMillis();
    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        start = System.currentTimeMillis();
        HttpSession session = httpServletRequest.getSession(true);
        Object user = session.getAttribute("user");
        if(user!=null){
            return true;
        }else{
            httpServletResponse.sendRedirect(httpServletRequest.getContextPath()+"/loginPage");
            return false;
        }
    }
}
